#include <at89c51RC2.h>
#include <intrins.h>

void Delay(unsigned char xms);
void GYSMG(unsigned x,y);


void main()
{
	while(1)
	{
		GYSMG(6,6);
//		Delay(1);
		GYSMG(5,5);
//		Delay(1);
		GYSMG(8,8);
//		Delay(1);
		GYSMG(7,7);
//		Delay(1);
		GYSMG(4,4);
//		Delay(1);
		GYSMG(3,3);
//		Delay(1);
		GYSMG(2,2);
//		Delay(1);
		GYSMG(1,1);
//		Delay(1);
//		GYSMG(8,8);
//		Delay(1);
	}
}

void GYSMG(unsigned x,y)//共阴数码管
{
	unsigned char GY[10]={0X3F,0X06,0X5B,0X4F,0X66,0X6d,0X7d,0X07,0X7F,0X6F};
	switch(x)
	{
		case 1:P2_2=0,P2_3=0,P2_4=0;break;
		case 2:P2_2=1,P2_3=0,P2_4=0;break;
		case 3:P2_2=0,P2_3=1,P2_4=0;break;
		case 4:P2_2=1,P2_3=1,P2_4=0;break;
		case 5:P2_2=0,P2_3=0,P2_4=1;break;
		case 6:P2_2=1,P2_3=0,P2_4=1;break;
		case 7:P2_2=0,P2_3=1,P2_4=1;break;
		case 8:P2_2=1,P2_3=1,P2_4=1;break;
	}
	P0=GY[y];
	Delay(1);     //消影，用延时达不到消影的效果
	P0=0x00;
}

void Delay(unsigned char xms)		//@11.0592MHz
{
	unsigned char i, j;

	while(xms--)
	{
		_nop_();
		i = 2;
		j = 199;
		do
			{
				while (--j);
			} while (--i);
	}
}
